import {createRouter, createWebHistory} from "vue-router";
import LoginView from "@/layout/LoginView.vue";
import RegistView from "@/layout/RegistView.vue";
import RegisterView2 from "@/layout/RegisterView2.vue";
import RegisterView3 from "@/layout/RegisterView3.vue";
import IndexView from "@/layout/IndexView.vue";
import BookDetail from "@/layout/BookDetail.vue";
import BookSearch from "@/layout/BookSearch.vue";
import CartView from "@/layout/cart/CartView.vue";
import CategoryFirstAdd from "@/layout/category/CategoryFirstAdd.vue";
import CategorySecondAdd from "@/layout/category/CategorySecondAdd.vue";
import AddBook from "@/layout/book/AddBook.vue";
import ManageView from "@/layout/back/ManageView.vue";
import BookView from "@/layout/back/BookView.vue";
import CategoryView from "@/layout/back/CategoryView.vue";
import OrderView from "@/layout/back/OrderView.vue";
import UserView from "@/layout/back/UserView.vue";
import UpdateBook from "@/layout/back/UpdateBook.vue";
import CategoryBook from "@/layout/category/CategoryBook.vue";
import PlaceOrder from "@/layout/order/PlaceOrder.vue";
import OrderDetail from "@/layout/back/OrderDetail.vue";
import AliPay from "@/layout/AliPay.vue";

const routes = [
    {
        path: "/", component: IndexView
    },
    {
        path: "/login", component: LoginView
    },
    {
        path: "/register", component: RegistView,
    },
    {
        path: "/validateEmail/:email", component: RegisterView2, name: "validateEmail"
    },
    {
        path: "/registerAll", component: RegisterView3, name: "registerAll"
    },
    {
        path: "/bookDetail/:bookId", component: BookDetail, name: "bookDetail"
    },
    {
        path: "/bookSearch/:bookName", component: BookSearch, name: "bookSearch"
    },
    {
        path: "/cart", component: CartView, name: "cart"
    },
    {
      path:"/placeOrder",component: PlaceOrder, name:"placeOrder"
    },
    {
        path:"/categoryBook/:categorySecondId",component: CategoryBook,name:"categoryBook"
    },
    {
        path: "/back/category/categoryAdd/first", component: CategoryFirstAdd, name: "categoryAddFirst"
    },
    {
        path: "/back/category/categoryAdd/second", component: CategorySecondAdd, name: "categoryAddSecond"
    },
    {
        path: "/back/book/addBook", component: AddBook, name: "addBook"
    },
    {
        path:"/back/book/updateBook/:selectId",component: UpdateBook,name:"updateBook"
    },
    {
        path:"/back/order/orderDetail/:orderId",component: OrderDetail,name:"orderDetail"
    },
    {
        path:"/front/order/alipay/:orderId",component: AliPay,name:"Alipay"
    },
    {
        path: "/back", component: ManageView, name: "manage",
        children: [
            {
                path: "/book", component: BookView, name: "book"
            },
            {
                path: "/category", component: CategoryView, name: "category"
            },
            {
                path: "/order", component: OrderView, name: "order"
            },
            {
                path: "/user",component: UserView,name:"user"
            }
        ]
    }
]

const router = createRouter(
    {
        history: createWebHistory(),
        routes: routes
    }
)

export default router